/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#ifndef GAME_GAME_GRIDDEFINES_H_
#define GAME_GAME_GRIDDEFINES_H_

#include <cmath>
#include <algorithm>
#include "Game/Common.h"

#define MAX_NUMBER_OF_GRIDS      64
#define SIZE_OF_GRIDS            533.33333f

#define MAP_SIZE                (SIZE_OF_GRIDS*MAX_NUMBER_OF_GRIDS)
#define MAP_HALFSIZE            (MAP_SIZE/2)

namespace Grid {

    inline bool isValidMapCoord(float c)
    {
        return finite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5);
    }

    inline bool isValidMapCoord(float x, float y)
    {
        return isValidMapCoord(x) && isValidMapCoord(y);
    }

    inline bool isValidMapCoord(float x, float y, float z)
    {
        return isValidMapCoord(x, y) && finite(z);
    }

    inline bool isValidMapCoord(float x, float y, float z, float o)
    {
        return isValidMapCoord(x, y, z) && finite(o);
    }

}

#endif /* GAME_GAME_GRIDDEFINES_H_ */
